package com.btl.component.crypto.aes.dto;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpInputMessage;
import org.springframework.lang.NonNull;

import java.io.ByteArrayInputStream;
import java.io.InputStream;


public class ByteArrayHttpInputMessage implements HttpInputMessage {

    private final byte[] body;
    private final HttpHeaders headers;

    public ByteArrayHttpInputMessage(byte[] body, HttpHeaders headers) {
        this.body = body;
        this.headers = headers != null ? headers : new HttpHeaders();
    }

    @Override
    @NonNull
    public InputStream getBody() {
        return new ByteArrayInputStream(body);
    }

    @Override
    @NonNull
    public HttpHeaders getHeaders() {
        return this.headers;
    }
}
